/**
 * 
 */
package com.zhengxing.jienci.common.support;

import java.util.HashMap;

/**
 * @author yyh
 *
 */
public class SimpleResponse extends HashMap<String, Object>{

	/**
	 * @Fields field:field:{todo}(用一句话描述这个变量表示什么)
	 */
	private static final long serialVersionUID = 1L;
	
	public static final String PARAMTER_CODE = "code";
	
	public static final String PARAMTER_MSG = "msg";
	
	public SimpleResponse() {
		put(PARAMTER_CODE, "200");
		put(PARAMTER_MSG, "操作成功");
	}
	
	public static SimpleResponse success(String code, String msg) {
		SimpleResponse simpleResponse = new SimpleResponse();
		simpleResponse.put(PARAMTER_CODE, code);
		simpleResponse.put(PARAMTER_MSG, msg);
		return simpleResponse;
	}
	
	public static SimpleResponse success(String msg) {
		return success("200", msg);
	}
	
	public static SimpleResponse success() {
		return success("操作成功");
	}
	
	public static SimpleResponse fail(String code, String msg) {
		SimpleResponse simpleResponse = new SimpleResponse();
		simpleResponse.put(PARAMTER_CODE, code);
		simpleResponse.put(PARAMTER_MSG, msg);
		return simpleResponse;
	}
	
	public static SimpleResponse fail(String msg) {
		return fail("500", msg);
	}
	
	public static SimpleResponse fail() {
		return fail("操作失败");
	}
	
	public SimpleResponse put(String msg, Object data) {
		super.put(msg, data);
		return this;
	}
	
}
